package fangzhiyi.testbank;

/**
 * @author south wind
 * @version 1.0
 * @date 2025/3/20 20:08
 * @description
 */
public class Bank {
    // 静态变量：用于统计所有银行的累计存款和取款金额
    private static double allTotalDeposit = 0; // 所有银行累计存款金额
    private static double allTotalWithdraw = 0; // 所有银行累计取款金额

    // 实例变量
    private String bankName; // 银行名称
    private String countryName = "中国"; // 所在国家名称
    private int totalCardNumber = 0; // 本银行已发出的卡数
    private double totalDeposit = 0; // 本银行累计存款金额
    private double totalWithdraw = 0; // 本银行累计取款金额

    // 构造方法
    public Bank(String bankName) {
        this.bankName = bankName;
    }

    // 发卡方法
    public BankCard createCard(String name, String personId) {
        BankCard card = new BankCard(name, personId);
        totalCardNumber++; // 更新本银行发卡数
        System.out.println(bankName + " 发卡成功，卡号: " + card.getBalance());
        return card;
    }

    // 存款方法
    public void deposit(BankCard card, double amount) {
        card.deposit(amount);
        this.totalDeposit += amount; // 更新本银行累计存款金额
        allTotalDeposit += amount; // 更新所有银行累计存款金额
    }

    // 取款方法
    public void withdraw(BankCard card, double amount) {
        card.withdraw(amount);
        this.totalWithdraw += amount; // 更新本银行累计取款金额
        allTotalWithdraw += amount; // 更新所有银行累计取款金额
    }

    // 获取本银行累计存款金额
    public double getTotalDeposit() {
        return this.totalDeposit;
    }

    // 获取本银行累计取款金额
    public double getTotalWithdraw() {
        return this.totalWithdraw;
    }

    // 静态方法：获取所有银行累计存款金额
    public static double getAllTotalDeposit() {
        return allTotalDeposit;
    }

    // 静态方法：获取所有银行累计取款金额
    public static double getAllTotalWithdraw() {
        return allTotalWithdraw;
    }

    // 打印银行信息
    @Override
    public String toString() {
        return "银行名称: " + bankName + ", 所在国家: " + countryName + ", 发卡数: " + totalCardNumber +
                ", 累计存款: " + totalDeposit + ", 累计取款: " + totalWithdraw;
    }
}


